package ACWing._872_最大公约数;

import java.util.Scanner;

public class Main {
    private static int maxyue(int a,int b){
        return b>0 ? maxyue(b,a%b):a;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.println(maxyue(a,b));
        }
        scanner.close();
    }

}
